/**
 * 登录检测
 */
 const { SuccessModel, ErrorModel } = require('../model/resModel')
 const { getCurrentTime } = require('./currentTime')

const loginCheck = async (ctx, next) => {
    if (ctx.session.username) {
        ctx.body = new SuccessModel({
            tip: '已登录',
            checkTime: getCurrentTime()
        }, '检测登录')
        await next()
    } else {
        ctx.body = new ErrorModel({
            tip: '未登录',
            failTime: getCurrentTime()
        }, '检测登录')
    }
}

module.exports = {
    loginCheck
}